﻿using Application.Dto;
using Application.IAppSrevices;
using AutoMapper;
using Domain.Entitys;
using Domain.Repositorys;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.AppSrevices
{
    public class RolesService : IRolesService
    {
        private readonly IRolesRepositoty rolesRepositoty;
        private readonly IMapper mapper;

        public RolesService(IRolesRepositoty rolesRepositoty, IMapper mapper)
        {
            this.rolesRepositoty = rolesRepositoty;
            this.mapper = mapper;
        }

        public int Add(int id, int id2)
        {
            return rolesRepositoty.Add(id,id2);
        }

        public int Delete(int id)
        {
         return rolesRepositoty.Delete(id);
        }

        public List<Jurisdiction> GetQX()
        {
           return rolesRepositoty.GetQX();
        }

        public List<XQ> GetQX2(string str)
        {
            return rolesRepositoty.GetQX2(str);
        }

        public int[] GetQXById(int id)
        {
           return rolesRepositoty.GetQXById(id);
        }

        public Roles GetRole(int id)
        {
          return rolesRepositoty.GetRole(id);
        }

        public List<Roles> GetRole2()
        {
            return rolesRepositoty.GetRole2();
        }

        public List<Roles> GetRoles(int a, int b)
        {
            return rolesRepositoty.GetRoles(a, b);
        }

        public int GetRolesCount()
        {
            return rolesRepositoty.GetRolesCount();
        }

        public List<User> GetUser(int a, int b)
        {
            return rolesRepositoty.GetUser(a, b);
        }

        public User GetUser2(int uid)
        {
            return rolesRepositoty.GetUser2(uid);
        }

        public int GetUserCount()
        {
            return rolesRepositoty.GetUserCount();
        }

        /// <summary>
        /// 角色管理表添加
        /// </summary>
        /// <param name="roles"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /*        public Task<int> RolesAdd(RolesDto rolesDto)
                {
                    RolesDto rolesDto1 = mapper.Map<CPC>(cPCAdd);
                    return await cPCRepositoy.CPCAddAsync(cPC);
                }*/

        public async Task<int> RolesAdd(RolesDto rolesDto)
        {
            Roles roles = new Roles();
            roles.RolesName = rolesDto.RolesName;
            roles.RolesInstruction = rolesDto.RolesInstruction;
            roles.RolesIf = rolesDto.RolesIf;
            return  await rolesRepositoty.RolesAdd(roles);
        }

        public async Task<int> RolesAdd1(Roles roles)
        {
            return await rolesRepositoty.RolesAdd(roles);
        }

        /// <summary>
        /// 修改角色信息
        /// </summary>
        /// <param name="roles"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public int RolesUpdate(Roles roles)
        {
            return rolesRepositoty.RolesUpdate(roles);
        }

        public int UserAdd(User user)
        {
            return  rolesRepositoty.UserAdd(user);
        }

        public int UserDelete(int uid)
        {
           return rolesRepositoty.UserDelete(uid);
        }

        public int UserUpdate(User user)
        {
           return rolesRepositoty.UserUpdate(user);
        }
    }
}
